var SwordForm = new Class({
    Implements:[Events,Options],
    Extends:PageContainer,
    name:"SwordForm",
    $family: {name: 'SwordForm'},
    options:{
        sword : null,//组件类型标识
        name : null, //组件唯一标识名
       /* caption:null,//form的标题栏
        layout:null,//组件的布局配置
*/        pNode:null, //组件的父对象
        /*panel:'false',//组件的panel栏
        beanname:null,//form表单对应于后台的BO的类型
        userDefine:'true',*///定义SwordForm为自定义布局,默认使用自定义，非自定义已经不推荐使用
		vType:"fldiv",        
		onFinish:$empty//数据装载完之后触发的事件
       /* size:null,//定义form里面各个元素的尺寸
        css:null///定义form里面各个元素的样式
        isValidate:'',//定义form是否需要增加校验
        vType:"fldiv",//定义form的校验提示类型
        topPanel:false,//是否创建顶层panel
        btmPanel:false,//是否创建底部的panel
        requiredSign:"caption",//必填的标志的位置。是跟随caption还是跟随field
        edit:null,//是否是只读form
        isShowTogdiv:false*/
    },
    el:{
        name:null,//name属性
        caption:null,//标题
        rule:null,//form元素item校验规则
        des:null,//form元素item的描述信息
        desType:null,//描述信息类型。是否是按钮还是文本
        biztid:null,//如果该元素需要进行后台的业务校验，则需要定义此属性，和定义tid一样
        bizctrl:null,//如果该元素需要进行后台的业务校验，则需要定义此属性，和定义ctrl一样
        vType:null,//某一个元素上的校验提示类型，可能暂时不生效
        scope:null,//业务校验提交数据的范围
        css :null,//样式设置,暂只支持某些items元素
        defValue:null,//默认值
        onValidate:null,//在进行校验时需要触发的方法
        onCreate:null,//在创建元素时调用
        maxLength:10000,//默认的输入长度限制
        msg:null,//提示信息
        dataformat:null,//数据格式的切换
        submitformat:null,
        format:null
        ,show:true//是否显示
        ,tipTitle:null//输入的提示信息
    },
    /*dftcss:{
        caption:null,//控制标题框的样式
        text:null//控制输入框的样式
    },*/
    /*dftsize:{
        ButtonWidth:75,//按钮的宽度
        ButtonWidth:75,//按钮的宽度
        CaptionWidth:80,//标题栏的宽度
        TdWidth:250,//操作栏TD的宽度
        FiledWidth:145,//操作栏的宽度(包括input，lable，textarea等等)
        DesWidth:170,//描述栏的宽度
        VimgWidth:17,//校验图片的宽度
        VimgHeight:21,//校验图片的高度
        VFiledWidth:180//校验框的总宽度
    },*/
   /* getEl:function(node) {
        var _el = $unlink(this.el);
        for(var key in _el) {
            _el[key] = node.get(key) || _el[key];
            if(key == "opts") {
                _el[key] = node.getChildren('>div');
            }
            if($type(_el[key]) == 'function' && (/^on[A-Z]/).test(key)) {
                _el[key] = new Function('param', _el[key]);
            }
        }
        return _el;
    },*/
    /*userSize:null,*/
    idx:0,//焦点转移顺序
    Vobj:null,//校验对象
    /*items : null,*///元素对象集合,所有元素的nodes集合
    /*itemsDiv: [],*///对象元素被浏览器解析之前的div集合
    /*layer : null,*///当前form的布局对象
    /*defAtts:['caption','name','des'],*///元素的title,元素的描述框
    /*elmodel:['div','item','div'],*///元素的title,元素�?元素的描述框
    /*blocks:[],*///block块数组
    hiddens:[],//隐藏元素集合
    hasFile:false,//当前form中是否有文件上传的提交
    wrapDiv:null,//最外层的wrapDiv
    /*noblock:'noblcok',*///判断当前是否有block元素
    /*lazyInitData:new Hash(),*///确保ie6下的checkbox，radio能够初始化,
    /*panel:null,*/
    fieldElHash:null,//用于存储元素，便于查询，用于getFieldEl接口
    fieldElOrderHash:null,//用于存储元素，焦点转移的顺序
    itemsIdArray:null,
//    x:null,
//    y:null,
    isHasFile:function() {
        return this.hasFile;
    },
    initParam:function(htmlNode) {
    	this.htmlOptions(htmlNode);
    	this.tooltips = pageContainer.create('SwordToolTips');
        this.fieldElHash = new Hash();
        this.Vobj = pc.widgetFactory.create("SwordValidator");
        this.Vobj.initParam(this.options.vType);
        this.initEvents(htmlNode);
        this.fireEvent("onFinish",this);
        /*if(this.tooltips == null) {
            this.tooltips = pageContainer.create('SwordToolTips');
        }
        this.fieldElHash = new Hash();
        this.fieldElOrderHash = new Hash();
        this.htmlOptions(htmlNode);
        this.userSize = JSON.decode(this.options.size);
        if($defined(this.userSize)) {
            this.dftsize = $extend(this.dftsize, this.userSize);
        }
        var userCss = JSON.decode(this.options.css);
        if($defined(userCss)) {
            this.dftcss = $extend(this.dftcss, userCss);
        }
        this.blocks = htmlNode.getChildren(">div[type='block']");
        this.items = htmlNode.getChildren(">div[console!='submit'][console!='reset'][console!='button']");
        if(htmlNode.getElements("div[type='file']").length > 0) {
            this.hasFile = true;
        }
        this.layer = SwordForm$Layout[this.options.layout]||SwordForm$Layout.deflayer;
        this.Vobj = pc.widgetFactory.create("SwordValidator");
        this.options.vType = this.options.vType || "intime";
        this.Vobj.initParam(this.options.vType);
        this.createForm();*/
    },
   /* createForm:function() {
        this.options.pNode.set({'class':'swordfrom_div','align':'center'});
        this.wrapDiv = new Element("div", {'align':'center','class':'swordfrom_wrap_div'}).inject(this.options.pNode,"top");
        if(this.options.topPanel == "true") {
            var div = new Element("div", {'class':'swordform_panel_top'}).inject(this.wrapDiv);
            div.set("html", "<div class='l'></div><div class='r'></div>");
        }
        if(this.options.panel == 'true') {
            this.panel = new SwordPanel({pNode:this.wrapDiv,caption:this.options.caption}).initParam();
            if(this.options.isShowTogdiv == "true") {
                new Element('div', {
                    'class':'x-tool',
                    'title':'收缩',
                    'events':{
                        'click':function(e) {
                            var tar = new Event(e).target;
                            var div = $splat(this.wrapDiv.getElement("div.swordform_block") || this.wrapDiv.getChildren('table'));
                            var tb = this.wrapDiv.getElement('div[sword=SwordToolBar]');
                            if(tb)div.include(tb);
                            if(tar.hasClass('x-tool-s')) {
                                tar.set('title', '收缩');
                                tar.removeClass("x-tool-s");//zk,suo
                                this.panel.tc.getParent().setStyle('border-bottom', 'none');
                                div.each(function(item, index) {
                                    if(item.hasClass('x-tool-dis') && item.getStyle("display") == "none") {
                                        item.setStyle("display", "");
                                        item.removeClass('x-tool-dis');
                                    }
                                }.bind(this));
                            } else {
                                tar.set('title', '展开');
                                tar.addClass("x-tool-s");//suo,zk
                                this.panel.tc.getParent().setStyle('border-bottom', '1px #7F9DB9 solid');
                                div.each(function(item, index) {
                                    if(item.getStyle("display") != "none") {
                                        item.setStyle("display", "none");
                                        item.addClass('x-tool-dis');
                                    }
                                }.bind(this));
                            }

                        }.bind(this)
                    }
                }).inject(this.panel.tc, 'top');
            }
        }
        if(this.options.userDefine != "true") {
            if(this.blocks.length == 0)this.blocks = [this.noblock];
            this.blocks.each(function(block) {
                var items,fieldset,layer;
                if(block == this.noblock) {
                    layer = this.layer;
                    items = this.items;
                    this.items.each(function(item, index) {
                        this.itemsDiv[index] = item.clone();
                    }.bind(this));
                    fieldset = new FormBlockArea({pNode:this.wrapDiv,caption:"",isHide:"false",name:"",isShow:'true'}).initParam();
                } else {
                    items = block.getChildren(">div");
                    fieldset = new FormBlockArea({pNode:this.wrapDiv,caption:block.get("caption"),isHide:block.get("isHide"),name:block.get("name"),isShow:block.get("isShow")}).initParam();
                    layer = ($defined(block.get("layout"))) ? eval(block.get("layout")) : this.layer;
                }
                var itemDiv = new Element('div', {'class':'swordform_items_div','height':'auto'}).inject(fieldset);
                items = items.filter(function(its) {
                    if(its.get('type') == 'hidden') {
                        this.hiddens.include(its);
                    }
                    return its.get('type') != 'hidden';
                }, this);
                var ems = items.splitForm(layer.cols);
                ems.each(function(em, idx) {
                    var div = new Element("div", {'class':'swordform_row_div'}).inject(itemDiv);
                    div.addClass(((idx + 1) % 2 == 0) ? "swordform_row_shuang" : "swordform_row_dan");
                    em.each(function(e, index, em) {
                        if(!$chk(e.get('name')) && e.get('type') != "userdefine") {
                            return;
                        }
                        var isLast = (index + 1 == em.length);
                        this._parseRow(div, e, layer, isLast);
                    }.bind(this));
                    //初始化时，根据show来显示隐藏item
                    em.each(function(el) {
                        if(el.get("show") == 'false') {
                            this.unDisplayItem(el.get('name'));
                        }
                    }.bind(this));
                }.bind(this));
            }, this);
            var hiddenDiv = new Element("div", {'styles':{'display':'none'}}).inject(this.wrapDiv);
            this.hiddens.each(function(hids) {
                this._parseRow(hiddenDiv, hids, this.layer);
            }, this);
            if(this.options.btmPanel == "true") {
                var div = new Element("div", {'class':'swordform_panel_btm'}).inject(this.wrapDiv);
                div.set("html", "<div class='l'></div><div class='r'></div>");
            }
            var bts = this.options.pNode.getChildren(">div[console]");
            var tr;
            bts.each(function(buton, idx) {
                if(idx == 0)tr = this.createConsole(this.wrapDiv);
                this.createButton(tr, buton);
            }.bind(this));
            if(jsR.config.swordForm.align == "center") {
                this.refreshForm();
            }
        } else {
            if($defined(this.wrapDiv)) {
                //自定义并且panel==false，去掉上面的这条线
                if(this.options.panel == 'false')this.wrapDiv.setStyle('border-style', 'none');
                this.options.pNode.grab(this.wrapDiv, "top");
            }
            this.wrapDiv = this.options.pNode;
            this.items = this.wrapDiv.getElements("div[type][name]");
            var item;
            var hiddenDiv = new Element("div", {'styles':{'display':'none'}}).inject(this.wrapDiv);
            for(var i = 0; i < this.items.length; i++) {
                item = this.items[i];
                if($chk(item.parentNode.getAttribute('sword'))&&item.parentNode.getAttribute('sword')!="SwordForm")continue;
                this.itemsDiv[i] = item.clone();
                if(item.get('type') == 'hidden' && item.get("yxbj") != 'false') {
                    this._parseItem(hiddenDiv, item);
                } else {
                    var p = item.getParent();
                    this._parseItem(p, item);
                    var newNode = p.getLast();
                    p.insertBefore(newNode, item);
                    item.setStyle("display", "none");
                }
            }
        }
        this.getFieldEls().filter(
                function(el) {
                    return (el.get("tag").toLowerCase() != "textarea");
                }).addEvent('keyup', this.nextFocus.bind(this));
        this.lazyInitData.each(function(v, k) {
            this.getWidget(k).initData(v, "ie6");
        }.bind(this));
        if(this.options.edit == "false") {
            this.disable();
        }
    },*/
    /*refreshForm:function() {
        var ROW_WIDTH = 0;
        var rows = this.options.pNode.getElements("div.swordform_row_div");
        rows.each(function(el, idx) {
            this.reSizeRow(el);
            var rowWidth = 0;
            el.getElements(".swordform_item_div").each(function(tab, index) {
                var width;
                if(tab.getFirst() && tab.getFirst().get("tag") == "table") {
                    width = tab.getFirst().getWidth().toInt();
                } else {
                    width = tab.getWidth().toInt();
                }
                rowWidth += width;
            }.bind(this));
            if(rowWidth > ROW_WIDTH)ROW_WIDTH = rowWidth;
        }.bind(this));
        rows.setStyle('width', ROW_WIDTH);
    },*/
    /*_parseRow:function(p, element, layer, isLast) {
        var itemdiv = new Element("div", {'class':'swordform_item_div','idx':this.idx}).inject(p);
        this.idx = this.idx + 1;
        var table = new Element('table', {'class':'swordform_item_table','cellspacing':0,'cellpadding':0,'border':0}).inject(itemdiv);
        var tbody = new Element('tbody').inject(table);
        layer.item.trs.each(function(em) {
            var tr = new Element('tr', {'class':'swordform_item_tr'}).inject(tbody);
            em.each(function(e) {
                var td = new Element('td', {'class':'swordform_item_' + e.name + '_td',
                    'colspan':$defined(e['colspan']) ? e['colspan'] : 1,
                    'rowspan':$defined(e['rowspan']) ? e['rowspan'] : 1
                }).inject(tr);
                var tag = this.elmodel[this.defAtts.indexOf(e.name)];
                if(tag == "item") {
                    if($defined(element.get("cols"))) {
                        var cols = element.get("cols") / 1;
                        td.setStyle("width", Sword.utils.valPx((this.dftsize.TdWidth * cols + this.dftsize.CaptionWidth * (cols - 1))));
                    } else {
                        td.setStyle('width', Sword.utils.valPx(this.dftsize.TdWidth));
                    }
                    if(isLast) {
                        td.setStyle("border-right", 0);
                    }
                    this._parseItem(td, element);
                } else {
                    if(e.name == "des" && element.get("desType") != null) {
                        var btn = $(element.get("desType"));
                        btn.clone().cloneEvents(btn).inject(td);
                    } else {
                        var node = new Element(tag, {'for':element.get("name"),'text':element.get(e.name),'class':'swordform_item_text_' + e.name}).inject(td);
                        if(e.name == "caption") {
                            var rule = element.get("rule");
                            if($chk(this.dftcss.caption) && $defined(this.dftcss.caption)) {
                                node.set("style", this.dftcss.caption);
                            }
                            node.setStyle('width', Sword.utils.valPx(this.dftsize.CaptionWidth));
                            node.set('text', element.get(e.name));
                            if($defined("rule") && $chk(rule)) {
                                if(rule.indexOf("must") > -1 && this.options.requiredSign == "caption") {
                                    node.innerHTML += "<span style='color:red'>*</span>";
                                }
                            }
                        }
                    }
                }
            }.bind(this));
        }.bind(this));
    },*/
    itemSwitch:function(name, type, options) {
    	//todo待重构
    	/*options=options||{};
        var defineItem = this.options.pNode.getElement("div[name='" + name + "']");
        var selDivAttributes = this.itemsDiv.filter(function(item) {
            return item.get('name') == name;
        })[0].attributes;
        var defiOptions = {};
        for(var i = selDivAttributes.length; i > 0;) {
            var key = selDivAttributes[--i].nodeName;
            if(/^on/.test(key))defiOptions[key] = selDivAttributes[i].nodeValue;
        }
        var CloneDefine = defineItem.clone(true);
        defineItem.set('type', type);
        defineItem.set(defiOptions);
        defineItem.set(options);
        if(this.options.requiredSign == "caption" && this.options.userDefine != 'true') {
            var rule = defineItem.get("rule");
            var hfor = this.wrapDiv.getElement("div[for='" + name + "']");
            if(hfor) {
                var mustSpan = hfor.getElement("span");
                if($defined(rule)) {
                    if(rule.indexOf("must") > -1) {
                        if(!mustSpan)hfor.innerHTML += "<span style='color:red'>*</span>";
                    } else {
                        if(mustSpan)mustSpan.destroy();
                    }
                } else {
                    if(mustSpan)mustSpan.destroy();
                }
            }
        }
        if(this.options.userDefine == 'true' && this.options.requiredSign == "caption" && $defined(options.rule)) {
            var rule = options.rule;
            var spanWrap = this.wrapDiv.getElement('*[span=' + name + ']');
            if(spanWrap && rule.indexOf("must") == -1) {
                var span = spanWrap.getElement('span.red');
                if(span)span.destroy();
            }
        }
        var obj = this.wrapDiv.getElement("*[name='" + name + "']");
        var ya = obj.retrieve('data');
        var value = obj.get('value') || obj.get('text');
        var isSel = false,allDb,rv;
        if(obj.get("widget") == "select") {
            isSel = true;
            allDb = obj.retrieve("allDb");
            rv = obj.get("realvalue");
        }
        var p = ['select','calendar','tree'].contains(obj.get('widget')) ? obj.getParent('table.swordform_field_wrap').getParent("td").empty() : obj.getParent("td").empty();
        this._parseItem(p, defineItem);
        var tar = p.getElement("*[name='" + name + "']");
        tar.set({'text':value,'value':value});
        if(tar.get('tag') == 'input')tar.addEvent('keyup', this.nextFocus.bind(this));
        if(isSel)tar.store("allDb", allDb).set("realvalue", rv).store('data', ya);
        if(this.options.userDefine == "true")CloneDefine.inject(p); else CloneDefine = null;*/
    }/*,
    isVal:function() {
        return (this.options.isValidate == 'true') || (this.options.vType == "elafter");
    }*/
    /*//------------------------------------------------------------------------------------------------------------------
    ,select:function(p, item, name) {
        var sel = pageContainer.getSelect();
        sel.setValidate(this.Vobj);
        sel.initParam(item, this);
        this.setWidget(name, sel);
        return sel.box;
    },
    label:function(p, item, name) {
        this.setWidget(name, null);
        var div = new Element('div', {'class':'swordform_field_wrap','styles':{'lineHeight':'20px'}}).inject(p);
        var vobj = new Element("label", this.getEl(item)).set({'text':item.get("defValue"),'class':'swordform_item_oprate swordform_item_label','styles':{'float':'left','overflow':'hidden'}}).inject(div);
         if(item.get("x") || item.get("y") || item.get("css")) {
         	var styles = "";
         	if(item.get("css")){
         		styles = styles + item.get("css")+ ";";
         	}
         	if(item.get("x")){
         		styles = styles + "width:" +Sword.utils.valPx(item.get("x"))+ ";";
         	}
         	if(item.get("y")){
         		styles = styles + "height:" + Sword.utils.valPx(item.get("y"))+ ";";
         	}
            vobj.set("style",styles).setStyles({"float":"left","overflow":"hidden"});
            if(vobj.getWidth() > this.dftsize.TdWidth)p.setStyle("width", "");
        }
        if(this.isVal() && $defined(item.get("rule"))) {
            Sword.utils.createElAfter(div);
        }
        return vobj;
    },
    textarea:function(p, item, name) {
        var div = new Element('div', {'class':'swordform_field_wrap'}).inject(p);
        item.pNode = div;
        var ta = new Textarea(item);
        this.setWidget(name, ta);
        
        var r= ta.initParam(this,div);
        var userW = Sword.utils.parseCss(ta.options.css, ta.box);
        Sword.utils.setWidth(userW, this.userSize, div, ta.box, false);

        return r;;
    }
    ,selectsolely:function(p, item) {
        return this.select(p, item);
    }
    ,checkbox:function(p, item, name) {
        var div = new Element('div', {'class':'swordform_field_wrap'}).inject(p);
        item.pNode = div;
        var group = new SwordGroupFields(item);
        group.initParam(item, this);
        this.setWidget(name, group);
        return  group.wrap;
    }
    ,radio:function(p, item, name) {
        return this.checkbox(p, item, name);
    }
    ,multiselect:function(p, item) {
        return this.checkbox(p, item);
    }
    ,file:function(p, item, name) {
        var div = new Element('div', {'class':'swordform_field_wrap'}).inject(p);
        item.pNode = div;
        var fileObj = new fileUpload(item).initParam(item, this);
        this.setWidget(name, fileObj);
        return fileObj.wrap;
    }*/
    ,file2:function(item,tempEl) {
    	var name=item.get("name");
    	var id=item.get("id");item.erase("id");
    	var fileObj=initUp4Template(tempEl.getParent(".swordform_field_wrap"),item,tempEl,this);
    	item.set("id",id);
    	pc.setWidget(this.options.name+"."+name, fileObj,item.get('dataName'));
    	this.setWidget(name, fileObj);
    	var vobj = fileObj.con;
        this.fieldElHash.set(name, vobj);
        vobj.addClass('swordform_item_oprate');
        vobj.set('widgetGetValue', 'true');
        vobj.set('widget', 'true');
        if($defined(item.get("rule"))) {
        	this.Vobj._add(vobj);
        }
        return vobj;
    	/*var p=item.getParent("td");
    	var name=item.get("name");
    	item.erase('id');
        var div = new Element('div', {'class':'swordform_field_wrap'}).inject(p);
        var up = initIntimeUp(div, name, item);
        this.setWidget(name, up);
        var vobj = up.con;
        vobj.set("id",this.options.name+"_"+name);
        this.fieldElHash.set(name, vobj);
        vobj.addClass('swordform_item_oprate');
        vobj.set('widgetGetValue', 'true');
        vobj.set('widget', 'true');
        if($defined(item.get("rule"))) {
        	this.Vobj._add(vobj);
        }
        return vobj;*/
    }
    /*,hidden:function(p, item, name) {
        return this.text(p, item,name);
    }
    ,password:function(p, item, name) {
        return this.text(p, item, name);
    }
    ,text:function(p, item, name) {
        this.setWidget(name, null);
        var div = new Element('div', {'class':'swordform_field_wrap'}).inject(p);
        var el = {type:item.get("type"),sf:item.get('submitformat'),d:item.get('defValue') || '',f:item.get('format') || '',r:item.get('rule') || '',n:name,m:item.get('msg'),t:item.get('tipTitle'),b:item.get("biztid"),bc:item.get('bizctrl')};
        var uw;
        if(this.userSize){
        	uw = Sword.utils.valPx(this.userSize.FiledWidth);
        }
        div.innerHTML = ["<input type='",el.type,"' bizctrl='",el.bc,"' submitformat=\"",el.sf,"\" defValue='",el.d,"' tipTitle='",el.t,"' biztid='",el.b,"' msg='",el.m,"' format=\"",el.f,"\" value='",el.d,"' rule='",el.r,"' id='",(this.options.name + '_' + el.n),"'  name='",el.n,"' class='swordform_item_oprate swordform_item_input' style='width:",uw,";float:left'>"].join("");//0511
        var vobj = div.getChildren("input")[0];
        this.cellTip(vobj, name);
        vobj.addEvent('focus', function() {
            vobj.select();
            this.showTip(name, vobj);
        }.bind(this));
        if(item.get("x") || item.get("y")||item.get("css")) {
        	var styles = "";
        	if(item.get("css")){
        		styles = styles + item.get("css") + ";";
        	}
        	if(item.get("x")) {
        		styles = styles + "width:" +  Sword.utils.valPx(item.get("x")) + ";";
        	}
        	if(item.get("y")){
        		styles = styles + "height:" + Sword.utils.valPx(item.get("y")) + ";";
        	}
            vobj.set("style",styles).setStyles({"float":"left"});;
        }
        
        if((item.get("rule") || "").indexOf("must") > -1 && this.options.requiredSign == "field") {
            new Element("span", {'styles':{'color':'red','float':'right'},'html':"*"}).inject(div);
        }
        if((item.get("rule") || "").indexOf("must") > -1 && this.options.requiredSign == "caption" && this.options.userDefine == 'true') {
            var spanWrap = this.wrapDiv.getElement('*[span=' + name + ']');
            if(spanWrap) {
                var span = spanWrap.getElement('span.red');
                if(!span)spanWrap.grab(new Element("span", {'class':'red','html':"*"}), 'top');
            }
        }
        if(this.isVal() && $defined(item.get("rule"))) {
            Sword.utils.createElAfter(div);
        }
        return vobj;
    }
    ,SwordSubmit:function(p, item, name) {
        var submit = pageContainer.create("SwordSubmit");
        submit.initParam(item);
    }
    ,date:function(p, item, name) {
        var cal = pageContainer.getCalendar();
        cal.setValidate(this.Vobj);
        var obj = cal.initParam(item, this);
        this.setWidget(name, cal);
        return cal.dateInput;
    }
    ,pulltree:function(p, item, name) {
    	var tree = pageContainer.create("SwordTree");
        this.setWidget(name, tree);
        pc.setWidget4loaddata(name, tree); //当pc.loaddata的时候会被调用
        tree.setValidate(this.Vobj);
        item.setProperty("select", "true");
        tree.initParam(item, this);
        tree.initData(item, this);
        var vobj = tree.select.selBox;
        if(this.isVal() && $defined(item.get('rule')))Sword.utils.createElAfter(vobj.getParent().getParent()=="tr", vobj=="input");
        return vobj;
    }*/
    ,validatecode:function(p, item, name) {
        var vc = pageContainer.getValidateCode();
        vc.initParam(item);
    }
   /* ,userdefine:function(p, item, name) {
        if(p.getPrevious() && !$defined(item.get('caption')))p.getPrevious().destroy();
        p.setStyle("width", "");
        var div = new Element('div', {'class':'swordform_userdefine_wrap'}).inject(p);
        item.getChildren().each(function(el) {
                el.clone(true).inject(div);
                el.setStyle("display", "none");
        }.bind(this));
        div.getElements("div[type][name]").each(function(el) {
            this._parseItem(div, el);
            var newNode = div.getLast();
            el.getParent().insertBefore(newNode, el);
            el.destroy();
            newNode.setStyle("float", "left");
        }.bind(this));
        if(this.isVal() && $defined(item.get("rule"))) {
            Sword.utils.createElAfter(div);
        }
    }
    ,_parseItem:function(p, item) {
        var tag = item.get("type");
        var name = item.get("name");
        if(!$defined(tag))tag = "text";
        var vobj;
        p.store("space", this.wrapDiv);
        item.pNode = p;
        vobj = this[tag](p, item, name);
        if($defined(vobj)) {
            if(Browser.Engine.trident) {//ff\ie相反的？
                sword_convertHTML(vobj, item);
                this.addFormatEvent(vobj);
                if($defined(item.get("rule")) && item.get("rule") != "")this.Vobj._add(vobj);
            } else {
                if($defined(item.get("rule")) && item.get("rule") != "")this.Vobj._add(vobj);
                this.addFormatEvent(vobj);
                sword_convertHTML(vobj, item);
            }
            if($defined(item.get("biztid"))||$defined(item.get("bizctrl")))
                vobj.addEvent('change', function(e) {
                    var tar = new Event(e).target;
                    this.bizValidate(tar);
                }.bind(this));
            if(item.get('nfidx'))this.fieldElOrderHash.set(item.get('nfidx') / 1, vobj);//自定义表单焦点转移的定义
            if(vobj.hasClass('swordform_item_oprate'))this.fieldElHash.set(item.get('name'), vobj);
            if(['text','textarea'].contains(tag) && (vobj.disabled || item.get('disable') == 'true')) this.disable(name);
            
            if(item.get('show')=="false")this.unDisplayItem(item.get('name'));
            
            
        }
    }*/,
    bizValidate:function(tar) {
        var rule = tar.get("rule");
        if(rule) {
            if(!this.Vobj.validate(tar))return;
        }
        if(!$defined(tar.get('value')))return;
        var req = this.getReq({
            'tid':tar.get('biztid'),
            'ctrl':tar.get('bizctrl'),
            'widgets':[this.getSubmitData()]
        });
        var valRes;
        pc.postReq({
            'async':false,
            'req':req
            ,'onSuccess':function(res) {
                if(res.success) {
                    valRes = true;
                    tar.removeClass("invalid");
                    this.Vobj.intimeValidate_Biz(tar, res.valiMsg || "校验成功!", true);
                } else {
                    valRes = false;
                    tar.addClass("invalid");
                    this.Vobj.intimeValidate_Biz(tar, res.valiMsg || "校验失败!", false);
                }
            }.bind(this)
            ,'onError':function() {
                valRes = false;
                if(this.options.vType == "elafter") {
                } else {
                }
            }
        });
        return valRes;
    },
    /*getExtraAtt:function() {
        return this.item.trs.flatten().filter(function(item) {
            return (!this.defAtts.contains(item.name));
        }, this);
    },*/
   /* createConsole:function(p) {
        var ct = new Element('div', {'class':'swordform_btns_ct'}).inject(p, 'bottom');
        var btns = new Element('div', {'class':'swordform_panel_btns swordform_panel_btns_center'}).inject(ct);
        var table = new Element('table', {'cellspacing':'0'}).inject(btns);
        var tbody = new Element('tbody').inject(table);
        return  new Element('tr').inject(tbody);
    },
    createButton:function(p, item) {
        var td = new Element('td', {'class':'swordform_panel_btn_td'}).inject(p);
        var table = new Element('table', {'class':'swordform_btn_wrap swordform_btn','styles':{'width':'75px'},'cellspacing':'0','cellpadding':'0','border':'0'}).inject(td);
        var tbody = new Element('tbody').inject(table);
        var tr = new Element('tr').inject(tbody);
        var tdL = new Element('td', {'class':'swordform_btn_left','html':'<i>&nbsp;</i>'}).inject(tr);
        var tdC = new Element('td', {'class':'swordform_btn_center'}).inject(tr);
        var em = new Element('em').inject(tdC);
        var button = new Element('button', {'class':'swordform_btn_text',
            'tid':item.get('tid'),
            'ctrl':item.get('ctrl'),
            'click':item.get('onClick'),
            'onClickBefore':item.get('onClickBefore'),
            'onClickAfter':item.get('onClickAfter'),
            'console':item.get('console'),
            'isRedirect':item.get('isRedirect'),
            'notClearProperties':item.get('notClearProperties')
        }).inject(em).appendText(item.getAttribute('caption'));
        button.set({
            'events':{
                'mouseover':function(e) {
                    var table = new Event(e).target.getParent(".swordform_btn_wrap");
                    table.addClass('swordform_btn_over');
                },
                'mouseout':function(e) {
                    var table = new Event(e).target.getParent(".swordform_btn_wrap");
                    table.removeClass('swordform_btn_over');
                }
            }
        });
        button.addEvent('click', function(e) {
            var b = new Event(e).target;
            var before = b.get('onClickBefore');
            var click = b.get('click');
            var after = b.get('onclickAfter');
            if($defined(before))
                this.getFunc(before)[0]();
            if($defined(click) && $chk(click) && b.get('console') != 'reset') {
                if($defined(click))this.getFunc(click)[0]();
                if($defined(after))this.getFunc(after)[0]();
            } else {
                if(b.get('console') == 'submit') {
                    if(!this.validate())return;
                    var req = this.getReq({'tid':b.get('tid'),'ctrl':b.get('ctrl'),'widgets':[this.getSubmitData()]});
                    if(this.hasFile && b.get('isRedirect') != "false") {
                        var cmit = this.getUploadCommit().initParam({'postData':req});
                        cmit.commit();
                    } else {
                        pc.postReq({
                            'req':req
                            ,'onSuccess': function(res) {
                                if(after) {
                                    this.getFunc(after)[0](req, res);
                                }
                            }.bind(this)
                            ,'onError':function(res) {
                                if(after) {
                                    this.getFunc(after)[0](req, res);
                                }
                            }.bind(this)
                        });
                    }
                } else if(b.get('console') == 'reset') {
                    var ncps = b.get("notClearProperties");
                    this.reset(ncps);
                    if($defined(after))this.getFunc(after)[0]();

                } else {
                    if($defined(click))this.getFunc(click)[0]();
                    if($defined(after))this.getFunc(after)[0]();
                }
            }
        }.bind(this));
        new Element('td', {'class':'swordform_btn_right','html':'<i>&nbsp;</i>'}).inject(tr);
    },*/
    initData:function(d) {
        if(!$chk(d)) {
            return;
        }
        if(d.initpage==true)return;//如果是页面初始化时候调用此接口，说明已经后台渲染了。
        this.reset();
        var opras = this.getFieldEls();
        if(d.sword == "SwordForm") {
            //var data = d.data;
            opras.each(function(em) {
            	var elName=em.get('name');
            	var dataValue=d.data[elName]?d.data[elName].value:"";
            	if(!(d.data[elName]===undefined)){
	                if(['true','select','calendar'].contains(em.get('widget'))) {
	                        this.getWidget(elName).initData(dataValue, em);
	                } else if(em.get('widget') == 'tree') {
	                        //下拉树的代码转名称
	                        var value = dataValue;
	                        if(value){
	                            if(value.contains("code") && value.contains("caption")) {
	                                var vs = value.split('|');
	                                if(value.contains('codePath')) {
	                                    //懒加载树的反显路径
	                                    em.set('codePath', vs[2].substring('codePath,'.length));
	                                }
	                                em.set('value', vs[1].split(',')[1]);
	                                em.set('realvalue', vs[0].split(',')[1]);
	                            } else {
	                                var tr = this.getWidget(elName);
	                                //var vs = value.split(',');
	                                this.initTreeData(value,tr.select.selBox);
	                                /*tr.select.show();
	                                tr.select.hide();
	                                var node = [];
	                                vs.each(function(v) {
	                                    var query = new Hash();
	                                    query.set(tr.options.cascadeSign.id, v);
	                                    node.include(tr.getTreeNode(query));
	                                });
	                                if(node) {
	                                    tr.setSelectedNode(node);
	                                } else {
	                                    tr.setSelectValue(dataValue);
	                                }*/
	                            }
	                        }
	                } else {
	                	  if(!$dateFmt(dataValue, em)) {
	                            em.set('value', dataValue);
	                            if(em.get("tag")=="label"){
	                            	dataValue=dataValue.replace(/\/n/g,"<br/>");
	                            	em.set('html', dataValue);
	                            	
	                            }else {
	                            	em.set('value', dataValue);
	                            }
	                      }
	                	  var code=d.data[elName].code;//只有label会有这个code
	                	  this.initFormatVal(em,code);
	                }
	                em.set('oValue', em.get('value'));
	               
            	}
            }.bind(this));
        } else {
            var wd = this.getWidget(d.name.split(".")[1]);
            if($defined(wd))
                wd.initOptionsData(d.data);
        }
    },
    getSubmitData:function() {
        var re = {
            'beanname':this.options.beanname,
            'sword':this.options.sword,
            'name' :this.options.name,
            'data' :{}
        };
        var itms = this.getFieldEls();
        itms.each(function(item) {
        	if(item.get('widgetgetvalue') == 'true') {
        		re['data'][item.get('name')] = {'value':this.getWidget(item.get('name')).getValue(item) || ""};
            } else if(item.get("widget") == "select") {
                re['data'][item.get('name')] = {'value':this.getWidget(item.get('name')).getValue(item)||item.get("realvalue")|| ""};
            } else {
                re['data'][item.get('name')] = {'value':item.get('realvalue') || item.get('value')||item.get("text")};
            }
        }, this);
        return re;
    },
    getGridData:function(gridname) {
        var re = {
            'beanname':this.options.beanname,
            'sword':'SwordGrid',
            'name' :gridname || '',
            'trs' :[
                {
                    'tds':this.getSubmitData().data
                }
            ]
        };

        return re;
    },
    getFormData:function() {
        var data = this.getSubmitData().data;
        var hash = new Hash();
        for(var d in data) {
            hash.include(d, data[d].value);
        }
        return hash;
    },
    getScrollW:function(w){ // 供validate使用，获取含有滚动条的父窗口对象
    	var hasScroll;
    	if(Browser.Engine.trident||Browser.Engine.gecko){
    		hasScroll=w.document.documentElement.scrollTop>0;
    	}else{
    		hasScroll=w.document.body.scrollTop>0;
    	}
    	if(hasScroll){return w;}
		else{
			w=w.parent;
			return this.getScrollW(w);
		}
    },

    validate:function(name) {
        var oprates = $chk(name) ? [this.getFieldEl(name)] : this.getFieldEls();
        var res = true;
        var errorEl=null;
        for(var i = 0; i < oprates.length; i++) {
            if($defined(oprates[i].get('rule'))) {
                if(!this.Vobj.validate(oprates[i])) {
                	if(!errorEl)errorEl=oprates[i];
                   
                    res = false;
//                     break;
                }
                if($defined(oprates[i].get('biztid')) || $defined(oprates[i].get('bizctrl'))) {
                    if(!this.bizValidate(oprates[i])) {
                    	if(!errorEl)errorEl=oprates[i];
                        res = false;
//                        break;
                    }
                }
            } else if($defined(oprates[i].get('biztid')) || $defined(oprates[i].get('bizctrl'))) {
                if(!this.bizValidate(oprates[i])) {
                	if(!errorEl)errorEl=oprates[i];
                    res = false;
//                    break;
                }
            }
        }
        if(errorEl){
        	try {
                //if(!$chk(name))oprates[i].focus();
                //if(errorEl.get('readonly') && (Browser.Engine.trident4 || Browser.Engine.trident5)) {
               	 this.getScrollW(window).scrollTo(0, errorEl._getPosition().y - 20);
                //}
            } catch(e) {
            }
        	errorEl.focus();
        }
        return res;
    },
    getField:function(name) {
        var w = this.getWidget(name);
        if(w && w.$family) {
            return this.getWidget(name);
        }
        return this.getFieldEl(name);
    },
    getFieldEl:function(name) {//增加需要调用set
        return this.fieldElHash.get(name);//this.options.pNode.getElement(".swordform_item_oprate[name='" + name + "']");
    },
    destroyFieldEl:function(name) {//从form中删掉某个元素，必须调用此接口
        if(!$defined(name))this.fieldElHash.empty();
        name = $splat(name);
        name.each(function(n) {
            this.fieldElHash.erase(n);
        }.bind(this));
    },
    getFieldEls:function() {
        return $$(this.fieldElHash.getValues());//this.options.pNode.getElements(".swordform_item_oprate");
    },
    getFieldElNames:function() {
        return this.fieldElHash.getKeys();//this.options.pNode.getElements(".swordform_item_oprate").get('name');
    },
    nextFocus:function(e) {
        e = Event(e);
        if(e.key == 'enter') {
            var tar = null;
            if(this.options.userDefine != "true") {
                var idx = e.target.getParent(".swordform_item_div").getAttribute("idx").toInt() + 1;
                var div = null;
                while(tar == null) {
                    try {
                        div = this.options.pNode.getElements(".swordform_item_div[idx='" + (idx) + "']")[0];
                        if(!div)return;
                        tar = div.getElement(".swordform_item_oprate");
                        if(!this.focusable(tar))tar = null;
                        idx++;
                    } catch(e) {
                        break;
                    }
                }
            } else {
                var name = e.target.get("name");
                var nfidx = this.fieldElOrderHash.keyOf(this.getFieldEl(name)) / 1;//自定义表单焦点转移的定义
                var size = this.fieldElOrderHash.getKeys().length;
                if(nfidx && nfidx != size) {
                    while(nfidx != null && tar == null) {
                        tar = this.fieldElOrderHash.get(nfidx + 1);
                        if(!this.focusable(tar))tar = null;
                        if(nfidx == size - 1)nfidx = null; else nfidx++;
                    }
                } else {
                    var ops = this.getFieldEls();
                    var idx = this.getFieldElNames().indexOf(name) + 1;
                    while(idx != ops.length && idx != null && tar == null) {
                        tar = ops[idx];
                        if(!this.focusable(tar))tar = null;
                        if(idx == ops.length - 1)idx = null; else idx++;
                    }
                }
            }
            if($defined(tar)) {
                tar.focus();
                tar.click();
            } else {
                e.target.blur();
            }
        }
    },
    isHide:function(el) {
        return el.getHeight() == 0 && el.getWidth() == 0;
    },
    focusable:function(tar) {
        return !(this.isHide(tar) || tar.get('disabled') || tar.get('readonly') || tar.get('_show') == 'false' || ['file','hidden'].contains(tar.get('type')) || !['input','textarea','file'].contains(tar.get('tag')));
    },
    /*toggleBlock:function(name) {
        var block = this.options.pNode.getElements(".swordform_block[name='" + name + "']")[0];
        if($defined(block)) {
            if(block.getStyle("display") == "none")block.setStyle("display", "");
            else block.setStyle("display", "none");
        }
    },
    hideBlock:function(name) {
        var block = this.options.pNode.getElements(".swordform_block[name='" + name + "']")[0];
        if($defined(block))block.setStyle("display", "none");
    },
    showBlock:function(name) {
        var block = this.options.pNode.getElements(".swordform_block[name='" + name + "']")[0];
        if($defined(block))block.setStyle("display", "");
    },*/
    hide:function(names) {
        if($type(names) == 'string')names = [names];
        names = names || [];
        names.each(function(name, index) {
            var field = this.getFieldEl(name);
            field.getParent(".swordform_field_wrap").setStyle("display","none");
        }.bind(this));
    },
    show:function(names) {
        if($type(names) == 'string')names = [names];
        names = names || [];
        names.each(function(name, index) {
        	var field = this.getFieldEl(name);
            field.getParent(".swordform_field_wrap").setStyle("display","");
        }.bind(this));
    },
    display:function() {
    	 Sword.utils.display(this.options.pNode);
    },
    undisplay:function() {
    	 Sword.utils.undisplay(this.options.pNode);
     }
    ,setValue:function(itemName, value) {
        var em = this.getFieldEl(itemName);
        if(!$defined(em))return;
        if(['true','select','tree','calendar'].contains(em.get('widget'))) {
            if(em.get('widget') == 'tree') {
                if(value.contains("code") && value.contains("caption")) {
                    var vs = value.split('|');
                    if(value.contains('codePath')) {
                        //懒加载树的反显路径
                        em.set('codePath', vs[2].substring('codePath,'.length));
                    }
                    em.set('value', vs[1].split(',')[1]);
                    em.set('realvalue', vs[0].split(',')[1]);
                } else {
                    var tree = this.getWidget(itemName);
                    var vs = value.split(',');
                    var caption = [];
                    vs.each(function(item){
                    	var nodeData = tree.treeDataHash.get(item);
                    	if($chk(nodeData))caption.push(nodeData.caption);
                    });
                    if(caption.length>0){
                    	tree.select.setValue(caption.split(","));
                    	tree.select.setRealValue(value);
                    }else if(value == ""){
                    	tree.select.setValue("");
                    	tree.select.setRealValue("");
                    }
                }
            } else {
                this.getWidget(itemName).initData(value, em);
            }
        } else {
            if(em.get('tag') == "label"){em.set({'text':value,'value':value});}
            else{
            	em.set({'realvalue':value,'value':value});
            }
        }
        //em.set('oValue', value);
        this.initFormatVal(em);
        this.validate(itemName);//todo,重新设置完的字段执行下校验.
    }
    ,getValue:function(name) {
        var Field = this.getField(name);
        if($type(Field) != 'element') {
            return Field.getValue(this.getFieldEl(name));
        }
        if(Field.get('tag').toLowerCase() == 'label')return Field.get('realvalue') || Field.get('text');
        return Field.retrieve("allDb") || Field.get('realvalue') || Field.get('value');
    },
    /*getTextValue:function(name) {
        return $(this.options.name + '_' + name).value;
    },
    setTextValue:function(name, value) {
        $(this.options.name + '_' + name).value = value;
    },*/
    reSizeRow:function(row) {
        if(!$defined(row))return;
        var oh = row.getHeight();
        var h = 0;
        row.getElements(".swordform_item_table").each(function(el) {
            var teph = el.getSize().y;
            if(h == 0)
                h = teph;
            else
                h = (h < teph) ? teph : h;
        });
        if(h > oh)row.setStyle('height', h);
    },
    clearField:function(name) {
        var item = this.getFieldEl(name);
        if(!$defined(item))return;
        if(item.get('widget') == "true" || item.get('widget') == "calendar") {
            var obj = this.getWidget(name);
            if($defined(obj) && $defined(obj.reset)) {
                obj.reset();
            } else {
                item.set('value', '');
                if(item.getAttribute('realvalue')) {
                    item.set("code", "");
                    item.set('realvalue', '');
                    item.set('oValue', '');
                }
                if(item.get('oValue'))item.set('oValue', '');
                this.Vobj.clearElTip(item);
            }
        } else {
            if(item.retrieve('allDb'))item.store('allDb', null);
            item.set('value', '');
            if(item.getAttribute('realvalue')) {
                item.set("code", "");
                item.set('realvalue', '');
                item.set('oValue', '');
            }
            this.Vobj.clearElTip(item);
        }
    },
    
    resetExcept: function(excepts){
    	var itemEls=this.options.pNode.getElements(".swordform_item_oprate");
    	if($chk(excepts)){
     		var resets =[];
     		itemEls.each(function(item){
    			if(excepts.indexOf(item.get("name")) == -1){
    				resets.push(item.get("name"));
    			}
    		});
     		this.reset(resets);
    	}
    },
    clearExcept: function(excepts){
    	var itemEls=this.options.pNode.getElements(".swordform_item_oprate");
    	if($chk(excepts)){
     		var clears=[];
     		itemEls.each(function(item){
    			if(excepts.indexOf(item.get("name")) == -1){
    				clears.push(item.get("name"));
    			}
    		});
     		this.clear(clears);
    	}
    },
    
    reset: function(resets) {
    	var itemEls=this.options.pNode.getElements(".swordform_item_oprate");
    	//var formData=pc.getInitData(this.options.name);
        if(!$chk(resets)){
        	itemEls.each(function(item){
        		if($chk(item.get("defValue"))){
	        		 var defValue = item.get("defValue");
	                 if(defValue!=null)this.setValue(item.get("name"), defValue);
	                 
        		}else{
        			this.clearItemData(item);
        		}
        		this.Vobj.clearElTip(item);
            }.bind(this));
        }else{
        	itemEls.each(function(item){
        		if(resets.indexOf(item.get("name")) != -1) {
        			if($chk(item.get("defValue"))){
               		    var defValue = item.get("defValue");
                        if(defValue != null)
                            this.setValue(item.get("name"), defValue);
               		}else{
            			this.clearItemData(item);
            		}
        		}
        		 this.Vobj.clearElTip(item);
            }.bind(this));
        }
//        var formData=pc.getInitData(this.options.name);
//        var p = this;
//        resets.each(function(i){
//        	p.setValue(i,formData.data[i].value);
//        });
//        var formData=pc.getInitData(this.options.name);
//        if(formData)formData.initpage=false;
//        if(formData)this.initData(formData);
        
    }
    ,clear:function(clearArray) {
    	/*若没有传入clearArray,全部清空,传入了就只清理clearArray中的想*/
    	var itemEls=this.options.pNode.getElements(".swordform_item_oprate");
        if(!$chk(clearArray)){
        	itemEls.each(function(item){
        		 this.Vobj.clearElTip(item);
        		this.clearItemData(item);
            }.bind(this));
        }else{
        	itemEls.each(function(item){
        		if(clearArray.indexOf(item.get("name")) != -1) {
	        		this.clearItemData(item);
	        		this.Vobj.clearElTip(item);
        		}
            }.bind(this));
        	 
        }
    }
    ,clearItemData:function(item){
    	if(item.get('widget') == "true" || item.get('widget') == "calendar") {
            var obj = this.getWidget(item.get("name"));
            if($defined(obj) && $defined(obj.reset)) {
                if(item.getElement("div[defvalue]"))return;//radio.checbox有defvalue时不执行清空操作。
                obj.reset();
            } else {
                item.set('value', '');
                item.set('text', '');
                if(item.getAttribute('realvalue')) {
                    item.set("code", "");
                    item.set('realvalue', '');
                }
                if(item.get('oValue'))item.set('oValue', '');
            }
    	} else {
            if(item.retrieve('allDb'))item.store('allDb', null);
            item.set('value', '');
            item.set('text', '');
            item.set('oValue', '');
            if(item.getAttribute('realvalue')) {
                item.set("code", "");
                item.set('realvalue', '');
            }
    	}
    }
    
    ,getRowData4Grid:function(){
    	 		var re = {"tds":{}} ;
    	        var itms = this.getFieldEls();
    	        itms.each(function(item) {
    	        	var widgetValue=item.get('widgetGetValue');
        	        if(widgetValue == 'true'||widgetValue=="select") {
    	                var widget=item.get('widget');
    	                if(widgetValue=="select"||widget=='tree'){
    	                	re['tds'][item.get('name')] = {'value':'code,'+this.getWidget(item.get('name')).getValue(item)+'|caption,'+item.get("value")};
    	                }else{
    	                	re['tds'][item.get('name')] = {'value':this.getWidget(item.get('name')).getValue(item)};
    	                }
    	            } else {
    	                re['tds'][item.get('name')] = {'value': item.get('value')};
    	            }
    	        }, this);
    	        return re;
    }
    /*,getSubmitData4Grid:function() {
        var re = {
            'beanname':this.options.beanname,
            'sword':this.options.sword,
            'name' :this.options.name,
            'data' :{}
        };
        var itms = this.getFieldEls();
        itms.each(function(item) {
            if(item.get('widgetGetValue') == 'true') {
                re['data'][item.get('name')] = {'value':this.getWidget(item.get('name')).getValue(item)};
            } else {
                re['data'][item.get('name')] = {'value': item.get('value')};
            }
        }, this);
        return re;
    }*/,
    //给对象增加format的处理
    //oValue:用户输入的最原始的值
    //realvalue:用户所需要提交的值的格式
    //value:用户需要显示出来的格式的值
    //showformat:用户定义显示的format
    //submitformat:用户定义需要提交的format
    //format:如果只定义了format属性，则表示提交的值默认是用户输入的值
    addFormatEvent:function(el) {
        if(!$defined(el))return;
        //目前暂时只支持以下二种类型
        if(el.get('type') == "label" ||el.get('type') == 'text') {
        	var wValue=el.get("widget");
            var nsFs=["calendar","select","pulltree"];
            if(nsFs.contains(wValue))return;
            if(!el.get('format') && !el.get('submitFormat'))return;
            //this.initFormatVal(el);
            if(el.get('tag') == 'label')return;
            el.addEvents({
                'focus':function() {
                    if(el.get('tag') == 'label')
                        el.set('text', el.get('oValue'));
                    else
                        el.set('value', el.get('oValue'));
                }.bind(this)
                ,'blur':function() {
                	this.initFormatVal(el);
                }.bind(this)
            });
        }
    },
    //初始化format的值
    initFormatVal:function(el,code) {
	    if($chk(code)){
	   		el.set('realvalue', code);
	   	 }
    	
        if(el.get('format')||el.get('submitFormat')) {
        	var key=(el.get("tag") == "label") ? "text" : "value";
        	el.set('oValue', el.get(key));
            if(!$chk(code)){
            	el.set('realvalue', this.getFormatVal(el, "submitFormat"));
            }
            el.set(key, this.getFormatVal(el));
            if(key=="text"){
            	el.set("html",el.get(key).replace(/\/n/g,"<br/>"));
            }
        }
    },
    //获取fomat之后的值
    getFormatVal:function(el, bz) {
        var format = el.get(bz);
        if(!$defined(bz))format = el.get("format");
        if(!$defined(format))return el.get("oValue");
        return sword_fmt.formatText(el, (el.get('tag') == 'label') ? el.get('text') : el.get('value'), '', format).value;
    },
    //暂时取消验证
    cancelVal:function() {
        this.Vobj.cancelV();
    },
    //激活验证
    activeVal:function() {
        this.Vobj.activeV();
    },
    /**
     * 删除指定标识的slect的选项数据
     * @name select的标识name的值
     */
    deleteSelectOptions:function(name) {
        var selInput = this.getFieldEl(name);
        if($chk(selInput.get('dataname')))
            pc.deleteDataByDataName(selInput.get('dataname'));
        if($chk(selInput.get('name')))
            pc.deleteDataByWidgetName(selInput.get('name'));
        var ca = this.getWidget(name).CacheData;
        if(ca && ca.has(name))ca.erase(name);
    },
    disable:function(names,codes) {
        if($type(names) == 'string')names = [names];
        names = names || [];
        //没有参数，默认全部
        if(names.length == 0) {
            names = this.getFieldElNames();
        }
        names.each(function(name, i) {
            var w = this.getWidget(name);
            if($defined(w)) {
                if($defined(w.disable)){
                	var tp = w.options.type;
                	if(tp=="checkbox" || tp=="radio"){
                		w.disable(this.getFieldEl(name),codes);
                	}else{
                		w.disable(this.getFieldEl(name));
                	}
                }
                if($type(w) == 'SwordTree' && $defined(w.select.disable))w.select.disable(this.getFieldEl(name));
                if($chk(w.box) && w.box.type == 'textarea')w.box.set('disabled', 'true').addClass('swordform_item_input_disable');
            } else {
                this.getFieldEl(name).set('disabled', 'true').addClass('swordform_item_input_disable');
            }
        }.bind(this));
    },
    enable:function(names,index) {
        if($type(names) == 'string')names = [names];
        names = names || [];
        //没有参数，默认全部
        if(names.length == 0) {
            names = this.getFieldElNames();
        }
        names.each(function(name, i) {
            var w = this.getWidget(name);
            if($defined(w)) {
                if($defined(w.enable)){
                	var tp = w.options.type;
                	if(tp=="checkbox" || tp=="radio"){
                		w.enable(this.getFieldEl(name),index);
                	}else{
                		w.enable(this.getFieldEl(name));
                	}
                }
                if($type(w) == 'SwordTree' && $defined(w.select.enable))w.select.enable(this.getFieldEl(name));
                if($chk(w.box) && w.box.type == 'textarea')w.box.erase('disabled').removeClass('swordform_item_input_disable');
            } else {
                this.getFieldEl(name).erase('disabled').removeClass('swordform_item_input_disable');
            }
        }.bind(this));
    }
    ,cellTip:function(input, name) {
        if($chk(input.get('tipTitle'))) {
            if(!this.tooltips.get(name)) {
                this.tooltips.createTip({
                    divId : name,
                    message : input.get('tipTitle'),
                    width:'200px',
                    'z-index':200
                });
                this.tooltips.getCont(name).addEvent("click", function(e) {
                    this.tooltips.hide(name);
                }.bind(this));
            }
        }
    }
    ,showTip:function(name, input) {
        if($chk(input.get('tipTitle')))
            this.tooltips.show(name, input, {'flag':'top','className':'warning','autoHidden':false});
    }
    ,initEvents:function(formEl){
    	if($chk(formEl.get("itemsId"))){
    		var elIdArray=formEl.get("itemsId").split(",");
    		this.itemsIdArray=elIdArray;
    		//var typeObj={date:"date",select:"select",pulltree:"pullTree"};
    		elIdArray.each(function(item){
                var el=$(item+"_tpl");
                if($chk(el)){
               	 var elTypeStr=el.get("type");
               	 var swordStr=el.get("sword");
                    var tplEl=$(item);
                    if(!elTypeStr&&!swordStr)elTypeStr="text";
                    else if(swordStr)return;//提交组件不处理
                    if(tplEl){
                    	this.eventForAll(el,tplEl);
                    	this.fieldElHash.set(el.get('name'), tplEl);
                    }
                    this[elTypeStr](el,tplEl,formEl);
                 }
            }.bind(this));
    	}else{
    		this.itemsIdArray=[];
    	}
    }
    /*
     	每个元素所应注册的事件
     	item原定义div
     	vobj解析后的input
     */
    ,eventForAll:function(item,vobj){
    	sword_convertHTML(vobj, item);//普通事件注册.
    	var tStr=item.get("type");
    	if(tStr!="text"&&tStr!="password"){
	    	if(item.get('format')||item.get('submitformat'))this.addFormatEvent(vobj);
	    	var types=["file2","date","select","pulltree"];
	        if(item.get("rule")&&!types.contains(tStr))this.Vobj._add(vobj);
    	}
        if($defined(item.get("biztid"))||$defined(item.get("bizctrl")))
            vobj.addEvent('change', function(e) {
                var tar = new Event(e).target;
                this.bizValidate(tar);
            }.bind(this));
        if(item.get('nfidx'))this.fieldElOrderHash.set(item.get('nfidx') / 1, vobj);//自定义表单焦点转移的定义
        if(vobj.hasClass('swordform_item_oprate'))this.fieldElHash.set(item.get('name'), vobj);
        if(item.get('show')=="false"&&item.get("type")!="pulltree")this.hide(item.get('name'));
    }
    ,hidden:function(item,tempEl){
    	this.text(item,tempEl);
    }
    ,file:function(item, tempEl) {
    	if(!this.hasFile)this.hasFile=true;
        var fileObj = new fileUpload(item);
        fileObj.initParam(item, this);
        fileObj.wrap = tempEl;
        fileObj.wrap.store("parent", this);
        fileObj.options.pNode = item.getParent();
        fileObj.innerWrap = tempEl.getElement(".formselect-list-inner");
        fileObj.box = tempEl.getElement("input[type='file']");
        fileObj.initEvent();
        this.setWidget(item.get("name"), fileObj);
    }
    ,date:function(item,tempEl){
    	  var dateObj=pageContainer.getCalendar();
          dateObj.setValidate(this.Vobj);
          dateObj.dateInput=tempEl;
          dateObj.dateBtn=tempEl.getParent("td").getNext().getElement(".dateBtn");
          $extend(dateObj.options,item);
          dateObj.addEventToEl("input");
          dateObj.addEventToEl("div");
          var name=tempEl.get("name");
          this.cellTip(tempEl, name);
    	  tempEl.addEvent('focus', function() {
    		tempEl.select();
            this.showTip(name, tempEl);
          }.bind(this));
          if(item.get("showCurDate")&&(item.get("showCurDate")!="false"))dateObj.setCurDate();
          this.setWidget(item.get("name"),dateObj);
          if("true"==item.get("disable"))dateObj.disable(tempEl);
          var rd = item.get("readonly") || item.getAttribute("readonly");
          if("true"== rd){
        	  tempEl.set("readonly","readonly");
          }else{
        	  tempEl.removeAttribute("readonly");
          }
    }
    ,select:function(item,tempEl,fEl,isdt){
          var selectObj=pageContainer.getSelect();
          selectObj.setValidate(this.Vobj);
          selectObj.box=tempEl;
          selectObj.box.getParent().store("space",this.options.pNode);
          selectObj.selDiv=tempEl.getParent("td").getNext().getElement(".swordselect-selimg");
          $extend(selectObj.options,item);
          selectObj.options.pNode=item;
          selectObj.initEvent();
          var name=tempEl.get("name");
      	  this.cellTip(tempEl, name);
    	  tempEl.addEvent('focus', function() {
    		tempEl.select();
            this.showTip(name, tempEl);
          }.bind(this));
    	  tempEl.addEvent('blur', function() {
    		  if($chk(tempEl.get('tipTitle'))) this.tooltips.hide(name);
    	  }.bind(this));
          this.setWidget(item.get("name"),selectObj);
          if("true"==item.get("disable"))selectObj.disable(tempEl);
          var rd = item.get("readonly") || item.getAttribute("readonly");
          if("true"== rd){
        	  tempEl.set("readonly","readonly");
          }else{
        	  tempEl.removeAttribute("readonly");
          }
          if(isdt){selectObj.initData(item.get("defValue"),tempEl);}
    }
    ,radio:function(item,tempEl,fEl,isDt){
        this.checkbox(item,tempEl,fEl,isDt);
    }
    ,checkbox:function(item,tempEl,fEl,isDt){
    	item.pNode=tempEl.getParent(".swordform_field_wrap");
        var group = new SwordGroupFields(item);
        group.wrap = tempEl;
        group.innerWrap=tempEl.getElement("div.formselect-list-inner");
        var tDataName=item.get('dataName');
        group.parent=this;
        if(isDt){
        	group.initOptionsData($chk(tDataName)?pc.getInitDataByDataName(tDataName):item.getChildren(">div"));
        }
        group.initEvent();
        tempEl.addEvent("click", function(){
        	if($chk(tempEl.get("rule"))){
			 	this.Vobj.validate(tempEl);
        	}
        }.bind(this));
        this.setWidget(item.get("name"),group);
        pc.setWidget(this.options.name+"."+name, group,tDataName);
    }
    ,password:function(item,tempEl,formEl){
    	this.text(item,tempEl,formEl);
    }
    ,text:function(item,vobj,formEl){
    	var name=vobj.get("name");
    	this.cellTip(vobj, name);
        vobj.addEvents({'focus':function() {
             vobj.select();
             if($chk(vobj.get('format'))){vobj.set('value', vobj.get('oValue'));}
             this.showTip(name, vobj);
        }.bind(this),"keyup":function(event) {
	       	 var e = Event(event);
	         if(e.key == 'enter') {
	        	 this.nextText(vobj,formEl);
	         }
        }.bind(this),"blur":function() {
    		 vobj.set("realvalue",vobj.get("value"));
 		     if($chk(vobj.get('tipTitle'))) this.tooltips.hide(name);
 		     if($chk(vobj.get("rule"))){
	 			 	this.Vobj.validate(vobj);
	 	     }
	 		this.initFormatVal(vobj);
 		}.bind(this)});
        if("true"==item.get("disable"))vobj.set("disabled","true");
        var rd = item.get("readonly") || item.getAttribute("readonly");
        if("true"== rd){
        	vobj.set("readonly","readonly");
        }else{
        	vobj.removeAttribute("readonly");
        }
    },nextText:function(vobj,formEl){
    	var vobjId = vobj.get("id");
    	var vobjIds =  formEl.get("itemsID").split(",");
    	var num = vobjIds.indexOf(vobjId)+1;
    	if(num<vobjIds.length)  $(vobjIds[num]).focus();
    	
    }
    ,textarea:function(item,tempEl,formEl){
        var ta = new Textarea(item);
        ta.box=tempEl;
    	this.cellTip(tempEl, ta.options.name);
    	tempEl.addEvent('focus', function() {
    		tempEl.select();
            this.showTip(ta.options.name, tempEl);
        }.bind(this));
    	tempEl.addEvent('blur', function() {
    		   if($chk(tempEl.get('tipTitle'))) this.tooltips.hide(ta.options.name);
        }.bind(this));
        ta.countSpan=tempEl.getParent().getElement("span");
        if(item.get("maxLength")){
            ta.initEvent();
        }
        ta.parent=this;
        this.setWidget(item.get("name"),ta);
        if("true"==item.get("disable"))tempEl.set("disabled","true");
        var rd = item.get("readonly") || item.getAttribute("readonly");
        if("true"== rd){
        	tempEl.set("readonly","readonly");
        }else{
       	 	tempEl.removeAttribute("readonly");
        }
        /*tempEl.addEvent('keyup', function(event) {
       	 var e = Event(event);
            if(e.key == 'enter') {
           	 this.nextText(tempEl,formEl);
            }
        }.bind(this));*/
    }
    ,label:function(item,tempEl){
    	
    }
    ,pulltree:function(item,tempEl){
    	 var divEl=new Element("div");
    	 divEl.inject(item.getParent("td"),"top");
    	 item.pNode=divEl;
    	 var id=tempEl.get("id"),tabindex=tempEl.get("tabindex");
    	 var tempSEl=item.getParent("td").getElement(".tree-select-wrap");
    	 if($chk(tempSEl))tempSEl.destroy();
         var tree = pageContainer.create("SwordTree");
         var name=item.get("name");
         this.setWidget(name, tree);
         pc.setWidget(this.options.name+"."+name, tree,item.get('dataName'));
//         pc.setWidget4loaddata(name, tree); //当pc.loaddata的时候会被调用
         tree.setValidate(this.Vobj);
         item.setProperty("select", "true");
         tree.initParam(item, this);
         tree.treeInForm=true;
         var data = item;
         if(item.get("dataStr")){
        	 data= item.get("dataStr");
         }
         tree.initData(data, this);
         var vobj = tree.select.selBox.set("id",id);
         tree.select.selBox.set("msg",item.get("msg")).set("tabindex",tabindex);
         vobj.addClass(item.get("class"));
         if(item.get("style").lastIndexOf("display: none;")!=0){
        	 vobj.set("style",vobj.get("style")+item.get("style"));
         }
         this.initTreeData(tempEl.get("realvalue")||tempEl.get("value"),vobj);//此处传入realvalue是兼容使用了dm2mc的情况 //todo:dm2mc应该移动到后台中实现。
         this.fieldElHash.set(name, vobj);
         if("true"==item.get("disable"))tree.select.disable(vobj);
         if($defined(item.get('rule')))this.Vobj._add(vobj);
         vobj.set("tipTitle",item.get("tipTitle"));
         var rd = item.get("readonly") || item.getAttribute("readonly");
         if("true"== rd){
        	 vobj.set("readonly","readonly");
         }else{
        	 vobj.removeAttribute("readonly");
         }
         this.cellTip(tree.select.selBox, name);
         tree.select.selBox.addEvent('focus', function() {
        	 tree.select.selBox.select();
             this.showTip(name,  tree.select.selBox);
         }.bind(this));
         tree.select.selBox.addEvent('blur', function() {
     		   if($chk(item.get('tipTitle'))) this.tooltips.hide(name);
         }.bind(this));
         if(item.get("show")=="false") this.hide(item.get("name"));
         return vobj;
    }
    ,pulllazytree:function(item,tempEl){
    	 var divEl=new Element("div");
    	 divEl.inject(item.getParent("td"),"top");
    	 item.pNode=divEl;
    	 var id=tempEl.get("id"),tabindex=tempEl.get("tabindex");
    	 var tempSEl=item.getParent("td").getElement(".tree-select-wrap");
    	 if($chk(tempSEl))tempSEl.destroy();
         var tree = pageContainer.create("SwordLazyTree");
         var name=item.get("name");
         this.setWidget(name, tree);
         pc.setWidget(this.options.name+"."+name, tree,item.get('dataName'));
//         pc.setWidget4loaddata(name, tree); //当pc.loaddata的时候会被调用
         tree.setValidate(this.Vobj);
         item.setProperty("select", "true");
         tree.initParam(item, this);
         tree.treeInForm=true;
         var data = item;
         if(item.get("dataStr")){
        	 data= item.get("dataStr");
         }
         tree.initData(data, this);
         var vobj = tree.select.selBox.set("id",id);
         tree.select.selBox.set("msg",item.get("msg")).set("tabindex",tabindex);
         vobj.addClass(item.get("class"));
         if(item.get("style").lastIndexOf("display: none;")!=0){
        	 vobj.set("style",vobj.get("style")+item.get("style"));
         }
         this.initTreeData(tempEl.get("realvalue")||tempEl.get("value"),vobj);//此处传入realvalue是兼容使用了dm2mc的情况 //todo:dm2mc应该移动到后台中实现。
         this.fieldElHash.set(name, vobj);
         if("true"==item.get("disable")) tree.select.disable(vobj);
         if($defined(item.get('rule'))) this.Vobj._add(vobj);
         vobj.set("tipTitle",item.get("tipTitle"));
         var rd = item.get("readonly") || item.getAttribute("readonly");
         if("true"== rd){
        	 vobj.set("readonly","readonly");
         }else{
        	 vobj.removeAttribute("readonly");
         }
         this.cellTip(tree.select.selBox, name);
         tree.select.selBox.addEvent('focus', function() {
        	 tree.select.selBox.select();
             this.showTip(name,  tree.select.selBox);
         }.bind(this));
         tree.select.selBox.addEvent('blur', function() {
     		   if($chk(item.get('tipTitle'))) this.tooltips.hide(name);
         }.bind(this));
         if(item.get("show")=="false") this.hide(item.get("name"));
         return vobj;
   }
    ,SwordSubmit:function(item,tempEl){
         //var tree = pageContainer.create("SwordTree");
    }
    //todo 此方法用来初始化form中树的数据,从initData中抽离的
    ,initTreeData:function(value,el){
    	if(value){
    		var tr = this.getWidget(el.get('name'));
            if(value.contains("code") && value.contains("caption")) {
                var vs = value.split('|');
                if(value.contains('codePath')) {
                    //懒加载树的反显路径
                    tr.select.selBox.set('codePath', vs[2].substring('codePath,'.length));
                }
                tr.setCaption(vs[1].split(',')[1]);
                tr.setRealValue(vs[0].split(',')[1]);
            } else {
            	var vs = value.split(',');
                var caption = [];
                var tObj=tr.getDataObj();
                if(!$chk(tObj)){
                	tObj=pc.getInitDataByDataName(tr.options.dataName);
                }
                if($chk(tObj)){
                	vs.each(function(v){
                    	tObj.data.each(function(item,index){
                    		if(item.code==v)caption.push(item.caption);
        	            });
                    });
                    if(caption.length>0){
                    	 tr.setCaption(caption.split(","));
                    	 tr.setRealValue(vs);
                     }
                	}
                else{
	                tr.setCaption(vs);
	                tr.setRealValue(vs);
                }
            }
        }
    }
    ,readonly:function(elN){
    	var el=this.fieldElHash.get(elN);
    	if($chk(el.get("type"))&&el.get("type")=="file2"){
    		if(!el.hasClass("sword_file_upload2_readonly")){
    			el.addClass("sword_file_upload2_readonly");
    		}
    	}else{
    		el.set("readonly","readonly");
    	}
    }
    ,editable:function(elN){
    	var el=this.fieldElHash.get(elN);
    	if($chk(el.get("type"))&&el.get("type")=="file2"){
    		if(el.hasClass("sword_file_upload2_readonly")){
    			el.removeClass("sword_file_upload2_readonly");
    		}
    	}else{
    		el.erase("readonly");
    	}
    }
    ,setRule:function(elName,rStr,msg){
    	var vobj=$(this.options.name+"_"+elName);
    	if($chk(vobj)){
	    	if($chk(rStr))vobj.set("rule",rStr);
	    	if($chk(msg))vobj.set("msg",msg);
	    	this.Vobj._add(vobj);
    	}
    }
    ,clearRule:function(elName){
    	var el=$(this.options.name+"_"+elName);
    	if($chk(el)){
	    	el.removeClass("invalid");
	    	el.erase("rule");
    	}
    },
    renderItems:function(){
    	var fName=this.options.name;
    	var pNodeEl=this.options.pNode;
    	var tempteObj={"text":'<div class="swordform_field_wrap" style="width:{wrapx};"><input id="temp" class="swordform_item_oprate swordform_item_input {class}" type="text"  style="width:{elx};{style}" oValue="{oValue}" name="{name}" rule="{rule}"  format="{format}"  msg="{msg}" bizctrl="{bizctrl}" biztid="{biztid}"  tipTitle="{tipTitle}"   defValue="{defValue}" submitFormat="{submitFormat}" show="{show}" value="{value}" autocomplete="off"></div>',
    			"select":'<table class="swordform_field_wrap" cellspacing="0" cellpadding="0" style="width:{wrapx};"><tbody><tr><td class="boxtd"><input class="swordform_item_oprate swordform_item_input swordform_item_input_bg swordform_item_input_plusImg {class}"  widgetGetValue="select" id="temp" type="text" widget="select" name="{name}" lines="{lines}" lineheight="21" vtype="fldiv"  style="width:{elx};{style}" dataFilter="{dataFilter}" dataName="{dataName}" cacheName="{cacheName}" defIndex="{defIndex}" value="{value}" code="{code}" handInput="{handInput}" defValue="{defValue}" on_change="{onChange}" onHide="{onHide}" onSelect="{onSelect}"  onShow="{onShow}" onSubmitBefore="{onSubmitBefore}" popWidth="{popWidth}" x="{x}" rule="{rule}" submitFormat="{submitFormat}" inputFormat="{inputFormat}" tipTitle="{tipTitle}" parent="{parent}" pcode="{pcode}"  displayCode="{displayCode}" handinput="{handinput}" addCaption="{addCaption}" addCode="{addCode}" biztid="{biztid}" bizctrl="{bizctrl}" msg="{msg}" show="{show}" popFormat="{popFormat}" autocomplete="off" realvalue="{code}" showAbstract="{showAbstract}"> </td> <td width="17px"> <div class="swordselect-selimg" style="float: left;" vtype="fldiv"></div> </td> </tr> </tbody> </table>',
    			"date":'<table class="swordform_field_wrap" cellspacing="0" cellpadding="0" style="width:{wrapx};"> <tbody> <tr> <td class="boxtd"> <input class="swordform_item_oprate swordform_item_input swordform_item_input_plusImg {class}" type="text" widget="calendar" id="temp"  on_change="{onChange}" onHide="{onHide}" rule="{rule}" biztid="{biztid}" bizctrl="{bizctrl}" style="width:{elx};{style}" defvalue="{defvalue}" show="{show}" tipTitle="{tipTitle}" msg="{msg}" showCurDate="{showCurDate}"  name="{name}" format="{format}" widgetgetvalue="true" submitFormat="{submitFormat}" showOptions="{showOptions}"  isShowCloseBtn="{isShowCloseBtn}" isShowEraseBtn="{isShowEraseBtn}" isShowTodayBtn="{isShowTodayBtn}" toZero="{toZero}" oValue="{value}" value="{value}" autocomplete="off"> </td> <td width="17px"> <div class="dateBtn" style="float: left;"></div> </td> </tr> </tbody> </table>',
    			"checkbox":'<div class="swordform_field_wrap" style="width:{wrapx};"> <div class="formselect-list swordform_item_oprate"  widget="true" id="temp"  widgetgetvalue="true" ruletype="checkboxGroup" style="width:{elx};"  name="{name}"   onClickAfter="{onClickAfter}" onClickBefore="{onClickBefore}"  rule="{rule}" biztid="{biztid}" bizctrl="{bizctrl}" defValue="{defValue}" value="{value}" show="{show}" msg="{msg}"  > <div class="formselect-list-inner"> </div> </div></div>',
    			"radio":'<div class="swordform_field_wrap" style="width:{wrapx};"> <div class="formselect-list swordform_item_oprate" name="{name}" id="temp" widget="true"  widgetgetvalue="true" ruletype="radioGroup"  style="width:{elx};" onClickAfter="{onClickAfter}" onClickBefore="{onClickBefore}"  rule="{rule}" biztid="{biztid}" bizctrl="{bizctrl}" defValue="{defValue}" show="{show}" msg="{msg}" value="{value}" > <div class="formselect-list-inner"> </div> </div> </div>',
    			"pulltree":'<div class="tree-select-wrap" wrapx="{wrapx}"> <input id="temp"  class="swordform_item_oprate swordform_item_input {class}" style="{style}" widget="pulltree" type="text" realvalue="{code}" value="{value}" defValue="{defValue}"  elx="{elx}" rule="{rule}" name="{name}" autocomplete="off"> </div>'};
    	/*
    	 * 根据itemsId查找选择需要动态渲染的元素数组,迭代渲染.
    	 */
    	//根据name判断是否已存在,若存在那么直接跳过.
    	var itemEls=pNodeEl.getElements("div[name]").filter(function(item){
    		var itemId=fName+"_"+item.get("name");
    		var isNY=!this.itemsIdArray.contains(itemId);
    		if(isNY){
    			this.itemsIdArray.push(itemId);
    			if(!$chk(item.get("type"))){item.set("type","text");}
    			item.set("id",itemId+'_tpl');
    		}
    		return isNY;
    	}.bind(this));
    	pNodeEl.set("itemsId",this.itemsIdArray);
    	itemEls.each(function(item){
    		var itemId=fName+"_"+item.get("name");
    		 var tStr=item.get("type");
    		 this.extendOpsForType(item);
    		 this.setRenderItemWidth(item);
    		 this.setRenderItemValue(item);
    		 var tempElStr=STemplateEngine.render(tempteObj[tStr],item,"");
    		 item.removeProperty("wrapx").removeProperty("elx");//删除和宽度相关的非定义属性
    		 var div = new Element('div',{'html':tempElStr});
    		 div.getChildren()[0].inject(item,"before");
    		 $('temp').set("id",itemId);
    		 item.set("style",";display:none;");
    		 var tplEl=$(itemId);
    		  if(tplEl){
              	this.eventForAll(item,tplEl);
              	this.fieldElHash.set(item.get('name'), tplEl);
              }
    		  this[tStr](item,tplEl,pNodeEl,true);
    	}.bind(this));
    	
    	///if(this.itemsIdArray.contains(fName+name)){}
    	
    },
    extendOpsForType:function(tempEl){
    	var tStr=tempEl.get("type");
    	if(tStr=="date"){
    		if(!$chk(tempEl.get("showoptions"))){
    			tempEl.set("showoptions",'true,true,true,false,false,false');
    		}
    		if(!$chk(tempEl.get("submitformat"))){
    			tempEl.set("submitformat",'Y-m-d H:i:s');
    		}
    		if(!$chk(tempEl.get("format"))){
    			tempEl.set("format",'Y-m-d');
    		}
    		if(!$chk(tempEl.get("isshowtodaybtn"))){
    			tempEl.set("isshowtodaybtn",'false');
    		}//修改isshowerasebtn默认值
    		if(tempEl.get("isshowerasebtn") == null || tempEl.get("isshowerasebtn") == "true" || tempEl.get("isshowerasebtn") == true){
    			tempEl.set("isshowerasebtn",'true');
    		}
    		if(!$chk(tempEl.get("isshowclosebtn"))){
    			tempEl.set("isshowclosebtn",'false');
    		}
    	}else if(tStr=="text"){
    		if($chk(tempEl.get("format"))){
    			tempEl.set("realvalue",'');
    		}
    	}else if(tStr=="select"){
    		if(!$chk(tempEl.get("displaycode"))){
    			tempEl.set("displaycode",'{displayCode}');
    		}
    		if(!$chk(tempEl.get("lines"))){
    			tempEl.set("lines",'10');
    		}
    	}
    },
    setRenderItemWidth:function(item){
    	var x=item.get("x");
    	if($chk(x)){
    		if(x.indexOf("%")!=-1){
    			item.set("wrapx", x);
    			item.set("elx", "100%");
    		}else{
    			if(x.indexOf("px")==-1){
    				x=x+"px";
    			}
    			var intx=x.substring(0, x.indexOf("px"));
    			item.set("wrapx", "auto");
				var typStr="date,select,pulltree";
				if(typStr.indexOf(item.get("type"))!=-1){
					item.set("elx", (intx-17)+"px");
				}else{
					item.set("elx", x);
				}
    		}
    	}
    },
    setRenderItemValue:function(item){
    	var defV=item.get("defValue"),tType=item.get("type");
    	
    	if($chk(defV)){
    		if(tType=="text"){
    			item.set("value",defV);
    		}
    	}
    },
    removeItem:function(name){
    	var pEl=this.options.pNode;
    	var fName=this.options.name;
    	if($type(name)=="string")name=[name];
    	name.each(function(item){
    		var elId=fName+"_"+item;
        	var itemId=elId+"_tpl";
        	var el=$(elId);
        	if(el){
	        	el.getParent(".swordform_field_wrap").destroy();
	        	$(itemId).destroy();
	        	this.itemsIdArray.erase(elId);
	        	this.fieldElHash.erase(item);
	        	pEl.set("itemsId",this.itemsIdArray);
        	}
    	}.bind(this));
    },
    removeItemsByEl:function(EL){
    	var fName=this.options.name;
    	var name=[];
    	EL.getElements("div[name][type]").each(function(item){
    		var elName=item.get("name");
    		var elId=fName+"_"+elName+"_tpl";
    		if(item.get("id")==elId){
    			name.push(elName);
    		}
    	});
    	this.removeItem(name);
    }
    ,modifyItem:function(name,opts){
    	//删除现在的html,新渲染renderItem.
    }
    ,setColWidth:function(name, width){
		var checkObj = this.getWidget(name);
		if($chk(checkObj) && $type(checkObj) == "groupfields"){
			var objs = checkObj.innerWrap.getElements(".formselect-list-item");
			if($chk(objs) && $chk(width)){
    			if(width.indexOf("%")==-1 && width.indexOf("px")==-1){
    				width=width+"px";
    			}
				objs.each(function(obj){
					obj.setStyle("width",width);
				});
			}
		}else{
			alert("此接口不支持该类型！");
		}
	}
    ,initLazyLoadData:function(res){
    	pc.loadData({'dataObj':res});
    }
});
